import axios from 'axios'
import React,{useEffect, useState} from 'react'
import {useParams} from "react-router-dom"
function Detail() {
  let {id} = useParams()
  let [obj,setObj] = useState({})
  useEffect(()=>{
    axios.get("/api/maoyanlist").then(res=>{
        // find 是找到符合他的那一项
       let newobj =  res.data.find(item=>item.id === id)
       setObj(newobj)
    })
  },[])
  console.log(id);
  
  return (
    <div>
        {
           obj.id && <div>
               <img src={obj.img} alt="" />
               <h4>标题:{obj.tit}</h4>
           </div>
        }
    </div>
  )
}

export default Detail